package com.c201801020208.ybl.Company.Activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.c201801020208.ybl.R;
import com.c201801020208.ybl.Tables.CompanyInfo;
import com.c201801020208.ybl.model.impl.ChatActivity;
import com.tencent.imsdk.v2.V2TIMConversation;
import com.tencent.qcloud.tim.uikit.modules.chat.base.ChatInfo;

public class JobInfoActivity extends AppCompatActivity {
    ImageView imageView;
    Button imageView2;
    TextView Username;
    TextView Jobname;
    TextView Discribe;
    TextView Worktime;
    TextView Companyname;
    TextView Salary;
    TextView Workexperience;
    TextView Address;
    TextView Education;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_job_info);

        imageView = findViewById(R.id.imageView3);
        imageView2 = findViewById(R.id.imageView6);
        Username = findViewById(R.id.textView21);
        Jobname = findViewById(R.id.textView25);
        Discribe = findViewById(R.id.textView24);
        Workexperience = findViewById(R.id.textView30);
        Worktime = findViewById(R.id.textView20);
        Address = findViewById(R.id.textView18);
        Education = findViewById(R.id.textView19);
        Companyname = findViewById(R.id.textView22);
        Salary = findViewById(R.id.textView26);


        CompanyInfo companyInfo = (CompanyInfo) getIntent().getSerializableExtra("companyInfo");
        Username.setText(companyInfo.getUsername());
        Jobname.setText(companyInfo.getJobname());
        Discribe.setText(companyInfo.getDescribe());
        Worktime.setText(companyInfo.getWorktime());
        Workexperience.setText(companyInfo.getWorkexperience());
        Address.setText(companyInfo.getAddress());
        Education.setText(companyInfo.getEducation());
        Companyname.setText(companyInfo.getCompanyname());
        Salary.setText(companyInfo.getMoney());

        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        //跳转至聊天页面
        imageView2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ChatInfo chatInfo = new ChatInfo();
                chatInfo.setType(V2TIMConversation.V2TIM_C2C);
                chatInfo.setId(Username.getText().toString());
                chatInfo.setChatName(Username.getText().toString());
                Intent intent = new Intent(JobInfoActivity.this, ChatActivity.class);
                intent.putExtra("CHAT_INFO", chatInfo);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
            }
        });
    }
}
